package cn.niit.service.impl;

import cn.niit.dao.TeacherDao;
import cn.niit.entity.Student;
import cn.niit.entity.Teacher;
import cn.niit.entity.query.TeacherQuery;
import cn.niit.service.TeacherService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 教师表(Teacher)表服务实现类
 *
 * @author makejava
 * @since 2021-11-14 16:07:57
 */
@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherDao teacherDao;

    @Override
    public PageInfo<Teacher> queryByTeacher(TeacherQuery teacherQuery) {
        PageHelper.startPage(teacherQuery.getPageNum(), teacherQuery.getPageSize());
        return new PageInfo<Teacher>(teacherDao.queryByTeacher(teacherQuery));
    }

    @Override
    public PageInfo<Teacher> queryByTeacherName(TeacherQuery teacherQuery) {
        PageHelper.startPage(teacherQuery.getPageNum(), teacherQuery.getPageSize());
        return new PageInfo<Teacher>(teacherDao.queryByTeacherName(teacherQuery));
    }

    @Override
    public PageInfo<Teacher> select(TeacherQuery teacherQuery) {
        PageHelper.startPage(teacherQuery.getPageNum(), teacherQuery.getPageSize());
        return new PageInfo<Teacher>(teacherDao.select(teacherQuery));
    }

    @Override
    public boolean editTeacher(Teacher teacher) {
        int i = teacherDao.editTeacher(teacher);
        return i > 0;
    }

    @Override
    public Teacher queryTeacherById(Integer id) {
        return teacherDao.queryTeacherById(id);
    }

    @Override
    public boolean addTeacher(Teacher teacher) {
        return teacherDao.addTeacher(teacher) > 0;
    }

    @Override
    public boolean deleteTeacherById(Integer id) {
        int i = teacherDao.deleteTeacherById(id);
        return i > 0;
    }
}